package com.vhall.component.entity.export.dto;

import com.vhall.component.plugin.common.utils.JsonUtil;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * admin导出通用查询条件
 *
 * @author yuanzh
 * @date 2021/11/23
 */
@Data
public class AdminExportCommonQueryCondition implements Serializable {

    private static final long serialVersionUID = -7142514839281463973L;

    /**
     * 查询关键字
     */
    private String keyword;

    /**
     * 开始时间
     */
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    private LocalDateTime endTime;

    /**
     * 转换查询json为查询对象
     *
     * @param queryCondition 查询条件
     * @return 查询对象
     */
    public static AdminExportCommonQueryCondition convertTo(String queryCondition) {
        if (StringUtils.isBlank(queryCondition)) {
            return null;
        }
        return JsonUtil.objectFromJSONString(queryCondition, AdminExportCommonQueryCondition.class);
    }

}
